

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;


public class HibernateDao {
	static SessionFactory factory=null;
	static {
		factory=new Configuration().configure("/hibernate.cfg.xml").buildSessionFactory();
		
	}
	public boolean insert(String pid,String laptop)
	{
		Session session=factory.openSession();
		Profile p=new Profile();
		p.setPid(pid);
		p.setLaptop(laptop);
		//p.setCost(cost);
		Transaction tx=session.beginTransaction();
		try{
			session.save(p);
			tx.commit();
		}catch(Exception er)	{
			
		
			System.out.println(er);
		return false;
		}
		
		return true;
	}
	/*public boolean update(int pid,String laptop,int cost)
	{
		Session session=factory.openSession();
		Profile p=new Profile();
		p.setPid(pid);
		p.setLaptop(laptop);
		p.setCost(cost);
		Transaction tx=session.beginTransaction();
		try{
			session.update(p);
			tx.commit();
		}catch(Exception er){
			System.out.println(er);
			return false;
		}
		
		return true;
	}
	public boolean delete(int pid)
	{
		Session session=factory.openSession();
		Profile p=new Profile();
		//Object o=(Employe)e;
		p.setPid(pid);
		
		Transaction tx=session.beginTransaction();
		try{
			session.delete(p);
			tx.commit();
		}catch(Exception er)	{
			System.out.println(er);
			return false;
		}
		
		return true;
	}
	public Object select(int pid)
	{
		Session session=factory.openSession();
				
		Object obj=session.get(Profile.class,pid);
		System.out.println(obj);
		
		
		return obj;
	}
	*/

}
